home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet multimedia / Animacje, filmy i prezentacje / Modelowanie 3D / K-3D 0.6.5.0 / k3d-all-in-one-setup-0.6.5.0.exe / k3d-setup-0.6.5.0.exe / share / shaders / k3d_rmannotes.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-03-17  |  1.5 KB  |  60 lines

  1. /* rmannotes.sl
  2.  * 
  3.  * macros to be used in conjunction with shaders described in
  4.  * the RManNotes web pages. 
  5.  *   http://www.cgrg.ohio-state.edu/~smay/RManNotes
  6.  *
  7.  */
  8. #include "k3d_noises.h"
  9. #include "k3d_filterwidth.h"
  10. #include "k3d_functions.h"
  11.  
  12. #define pulse(a,b,fuzz,x) (smoothstep((a)-(fuzz),(a),(x)) - \
  13.                smoothstep((b)-(fuzz),(b),(x)))
  14.  
  15. #define repeat(x,freq)    (mod((x) * (freq), 1.0))
  16.  
  17. #define odd(x)            (mod((x), 2) == 1)
  18. #define even(x)           (mod((x), 2) == 0)
  19.  
  20. #define whichtile(x,freq) (floor((x) * (freq)))
  21.  
  22. /* rotate2d()
  23.  *
  24.  * 2D rotation of point (x,y) about origin (ox,oy) by an angle rad.
  25.  * The resulting point is (rx, ry).
  26.  *
  27.  */
  28. #define rotate2d(x,y,rad,ox,oy,rx,ry) \
  29.   rx = ((x) - (ox)) * cos(rad) - ((y) - (oy)) * sin(rad) + (ox); \
  30.   ry = ((x) - (ox)) * sin(rad) + ((y) - (oy)) * cos(rad) + (oy)
  31.  
  32. /* topolar2d()
  33.  * 
  34.  * 2D cartesian -> polar coordinates
  35.  * converts the point (x,y) to radius 'r' and angle 'theta' (in radians).
  36.  * theta will be in the range [-PI,PI].
  37.  *
  38.  */
  39. #define topolar2d(x, y, r, theta) \
  40.   r = sqrt((x) * (x) + (y) * (y)); \
  41.   theta = atan(y, x) 
  42.  
  43. /* boolean ops (from Perlin85)
  44.  *
  45.  */
  46. #define intersection(a,b) ((a) * (b))
  47. #define union(a,b)        ((a) + (b) - (a) * (b))
  48. #define difference(a,b)   ((a) - (a) * (b))
  49. #define complement(a)     (1 - (a))
  50.  
  51.  
  52. /* blend() and lerp() are equivalent. blend() is used as a substitute for
  53.  * mix because it allows non-scalar 3rd arguments.
  54.  *
  55.  */
  56. #define blend(a,b,x) ((a) * (1 - (x)) + (b) * (x))
  57. #define lerp(a,b,x)  ((a) * (1 - (x)) + (b) * (x))
  58.  
  59.  
  60.